<?php
/**
 * Created by PhpStorm.
 * User: 狗剩先生
 * Date: 2018/12/22
 * Time: 17:41
 */

namespace app\admin\model;

use think\Model;

class User extends Model
{
    protected $autoWriteTimestamp = true;

    #   修改器
    public function setPsdAttr ($val)
    {
        return md5($val);
    }
    #   获取器
    public function getSexAttr ($val)
    {
        switch ($val){
            case '1':
                return  '男';
                break;
            case '2':
                return '女';
                break;
            default :
                return '未知';
                break;
        }
    }

    public function getUser ()
    {
        $result = $this->where('status',0)
            ->order('id desc')
            ->paginate(5);
        return $result;
    }

    public function getSearchResult ($data = [])
    {
        $order = ['id' => 'desc'];
        print_r($data);
        $res=$this->where($data)->order($order)->paginate(5);
        echo $this->getLastSql();
        dump($res);
        return $res;
    }

}